package com.wanjia.estate.utils;

import lombok.extern.slf4j.Slf4j;

import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.util.Base64;

@Slf4j
public class Base64Util {
    public static void stringToImage(String base64String,String name){
        byte[] decodedBytes = Base64.getDecoder().decode(base64String);
        try {
            OutputStream os = new FileOutputStream(name+".png"); // 将解码后的字节数组保存为图片
            os.write(decodedBytes);
            os.close();
            log.info("图片解码已成功");
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
